package com.milotnt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.milotnt.mapper.ClassTableMapper;
import com.milotnt.pojo.ClassTableEntity;
import com.milotnt.service.ClassTableService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
@Transactional
public class ClassTableServiceImpl extends ServiceImpl<ClassTableMapper, ClassTableEntity> implements ClassTableService {

    @Autowired
    private ClassTableMapper classTableMapper;

    @Override
    public List<ClassTableEntity> findAll() {
        LambdaQueryWrapper<ClassTableEntity> queryWrapper = new LambdaQueryWrapper<>();
        return classTableMapper.selectList(queryWrapper);
    }

    @Override
    public Boolean deleteClassByClassId(Long classId) {
        return classTableMapper.deleteClassByClassId(classId);
    }

    @Override
    public Boolean insertClass(ClassTableEntity classTable) {
        Date date = new Date();
        classTable.setUpdateTime(date);
        return classTableMapper.insertClass(classTable);
    }

    @Override
    public ClassTableEntity selectByClassId(Long classId) {
        return classTableMapper.selectByClassId(classId);
    }

    @Override
    public Boolean deleteOrderByClassId(Long classId) {
        return classTableMapper.deleteOrderByClassId(classId);
    }
}
